package com.gzhryc.shared_device.oem.code.user.dao.db;

import com.gzhryc.common.NumberTools;
import com.gzhryc.jdbc.annotaion.*;
import com.gzhryc.shared_device.common.payment.dao.db.PayAccountGroup;
import com.gzhryc.shared_device.oem.code.user.dao.enums.UserWalletEnum;

import java.io.Serializable;
import java.util.Date;

@Table(name = "user_wallet")
public class UserWallet implements Serializable {

    private static final long serialVersionUID = 1L;

	@PrimaryKey
    @Column(name = "user_id", note = "用户ID")
    protected Long userId;

    @PrimaryKey
    @Column(name = "account_group_id", notNull = true, note = "账号组ID")
    protected Long accountGroupId;

    @Column(name = "money", notNull = true, defVal = "0", note = "钱包余额，精确到厘")
    protected Long money;

    @Column(name = "withdrawal_money", notNull = true, defVal = "0", note = "提现金额，精确到厘")
    protected Long withdrawalMoney;

    @Column(name = "freeze_money", notNull = true, defVal = "0", note = "冻结的金额，精确到厘")
    protected Long freezeMoney;

    @Column(notNull = true, defVal = "1",note = "钱包状态")
    protected Integer state;

    @Column(name = "last_update_date", note = "最后修改余额时间")
    protected Date lastUpdateDate;

    @Column(name = "last_update_wm_date", note = "最后修改提现金额时间")
    protected Date lastUpdateWMDate;

    @Column(name = "last_update_fm_date", note = "最后修改冻结金额时间")
    protected Date lastUpdateFMDate;

    @Column(name = "update_date", autoUpdateTime = true)
    protected Date updateDate;

    @Column(name = "create_date")
    protected Date createDate;

    @Join(fromField = "account_group_id")
    protected PayAccountGroup accountGroup;
    
    @Join(fromField = "user_id")
    protected User user;

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public Long getAccountGroupId() {
        return accountGroupId;
    }

    public void setAccountGroupId(Long accountGroupId) {
        this.accountGroupId = accountGroupId;
    }

    public Long getMoney() {
        return money;
    }

    public void setMoney(Long money) {
        this.money = money;
    }

    public Long getFreezeMoney() {
        return freezeMoney;
    }

    public void setFreezeMoney(Long freezeMoney) {
        this.freezeMoney = freezeMoney;
    }

    public Long getWithdrawalMoney() {
        return withdrawalMoney;
    }

    public void setWithdrawalMoney(Long withdrawalMoney) {
        this.withdrawalMoney = withdrawalMoney;
    }

    public Date getLastUpdateDate() {
        return lastUpdateDate;
    }

    public void setLastUpdateDate(Date lastUpdateDate) {
        this.lastUpdateDate = lastUpdateDate;
    }

    public Date getLastUpdateWMDate() {
        return lastUpdateWMDate;
    }

    public void setLastUpdateWMDate(Date lastUpdateWMDate) {
        this.lastUpdateWMDate = lastUpdateWMDate;
    }

    public Date getLastUpdateFMDate() {
        return lastUpdateFMDate;
    }

    public void setLastUpdateFMDate(Date lastUpdateFMDate) {
        this.lastUpdateFMDate = lastUpdateFMDate;
    }

    public Integer getState() {
        return state;
    }

    public void setState(Integer state) {
        this.state = state;
    }

    public Date getUpdateDate() {
        return updateDate;
    }

    public void setUpdateDate(Date updateDate) {
        this.updateDate = updateDate;
    }

    public Date getCreateDate() {
        return createDate;
    }

    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    public PayAccountGroup getAccountGroup() {
        return accountGroup;
    }

    public void setAccountGroup(PayAccountGroup accountGroup) {
        this.accountGroup = accountGroup;
    }

    public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public String getMoneyStr(){
        return NumberTools.getMoneyLiStr(this.money);
    }

    public String getFreezeMoneyStr(){
        return NumberTools.getMoneyLiStr(this.freezeMoney);
    }

    public String getWithdrawalMoneyStr(){
        return NumberTools.getMoneyLiStr(this.withdrawalMoney);
    }

    public String getStateName(){
        return UserWalletEnum.State.note(this.state);
    }
}
